package com.itany.corejava.code03_分支结构;

import java.util.Scanner;

/**
 * @author: 石小俊
 * @date: 2023年03月02日 9:42
 * @version: 1.0
 */
public class Test09_switch获取天数 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("请输入一个合法的年份:");
        int year = sc.nextInt();
        System.out.print("请输入一个合法的月份:");
        int month = sc.nextInt();
        int day;
        switch (month) {
            case 2:
                if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
                    day = 29;
                } else {
                    day = 28;
                }
                break;
            case 4:
            case 6:
            case 9:
            case 11:
                day = 30;
                break;
            default:
                day = 31;
                break;
        }
        System.out.println(year+"年"+month+"月共有"+day+"天");
    }
}
